<?php
declare (strict_types=1);

namespace app\model\admin;

use app\common\model\BaseModel;
use \libs\Log;

class Notice extends BaseModel
{
    protected $pk = 'id';

    protected function initialize()
    {
        parent::initialize();
    }

    public function getOne($data, $fields = '*')
    {
        $info = self::where($this->pk, $data['id'])->field($fields)->find();
        return $info;
    }

    /**
     * 更新
     * @param array $data
     * @return array
     */
    public function edit(array $data, $field)
    {
        $where['id'] = $data['id'];
        $fieldArr = explode(',', $field);
        $this->allowField($fieldArr)
            ->update($data, $where);
        return $this->returnSucc('编辑成功');
    }
}
